package cn.iocoder.yudao.module.dt.dal.mysql.wxnews;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.dt.dal.dataobject.wxnews.WxNewsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.dt.controller.admin.wxnews.vo.*;

/**
 * 新闻 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface WxNewsMapper extends BaseMapperX<WxNewsDO> {

    default PageResult<WxNewsDO> selectPage(WxNewsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WxNewsDO>()
                .eqIfPresent(WxNewsDO::getTitle, reqVO.getTitle())
                .eqIfPresent(WxNewsDO::getNewsContent, reqVO.getNewsContent())
                .eqIfPresent(WxNewsDO::getPictureUrl, reqVO.getPictureUrl())
                .eqIfPresent(WxNewsDO::getRank, reqVO.getRank())
                .eqIfPresent(WxNewsDO::getIsShow, reqVO.getIsShow())
                .betweenIfPresent(WxNewsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WxNewsDO::getId));
    }

    default List<WxNewsDO> selectList(WxNewsExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<WxNewsDO>()
                .eqIfPresent(WxNewsDO::getTitle, reqVO.getTitle())
                .eqIfPresent(WxNewsDO::getNewsContent, reqVO.getNewsContent())
                .eqIfPresent(WxNewsDO::getPictureUrl, reqVO.getPictureUrl())
                .eqIfPresent(WxNewsDO::getRank, reqVO.getRank())
                .eqIfPresent(WxNewsDO::getIsShow, reqVO.getIsShow())
                .betweenIfPresent(WxNewsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WxNewsDO::getId));
    }

}
